<%--
  Created by IntelliJ IDEA.
  User: cyliu
  Date: 2022/10/14
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>
</head>
<body>
    <form id="f">
        <input id="um" type="text" name="username">用户名 <div id="m"></div> <br>
        <input type="password" name="password">密码 <br>
        <input type="button" value="用户注册" id="b">
    </form>
    <script src="${pageContext.request.contextPath}/js/jquery1.8.3.js"></script>
    <script>
        $("#um").blur(function (){
            // console.log(111111)
            let username = $(this).val();
            // console.log(username)

            let url = "http://localhost:8080/ssm_demo/user/findUser_by_username/"+username;

            $.ajax({
                url:url,
                type:"get",
                dataType:"json",
                success:function (responseData){
                    console.log(responseData);
                    if (responseData.code == 0){
                        $("#m").html("用户名已被注册")
                        $("#m").css("color","red");
                    }else {
                        $("#m").html("用户名合法")
                        $("#m").css("color","green");
                    }
                }
            })



        })
    </script>
</body>
</html>
